<template>
    <div class="detail-box">
        <!-- 电影名称 -->
        <div class="film-name">{{details.filmName}}</div>
        <!-- 电影信息 stat-->
        <div class="film-info">
            <div class="film-tip">
                <div class="comment-count">
                    <div class="film-source">
                        <span class="star-img open"></span>
                        <span class="star-img open"></span>
                        <span class="star-img open"></span>
                        <span class="star-img close"></span>
                        <span class="star-img close"></span>
                        <span class="star-source">{{details.source}}</span>
                    </div>
                    <div class="star-count">93601短评</div>
                </div>
                <div class="film-desc">
                    <p>
                        <span>上映时间:</span>{{details.filmYear}}</p>
                    <p>
                        <span>电影类型:</span>{{details.filmTypes}}</p>
                    <p>
                        <span>参演明星:</span>{{details.castNames}}</p>
                </div>
            </div>
            <div class="film-img" :style="`background-image: url(${details.filmImg})`"></div>
        </div>
        <!-- 电影信息 end-->
        <!-- 电影简介 start -->
        <div class="film-plot">
            <div class="plot-title">剧情简介</div>
            <div class="plot-content">
                {{details.filmDesc}}
            </div>
        </div>
        <!-- 电影简介 end -->
        <!-- 演员列表 -->
        <div class="film-actor">
            <div class="actor-title">导演演员</div>
            <div class="actor-list">
                <div class="actor-item" v-for="(item, index) in getCastList" :key="index">
                    <div class="actor-img" :style="`background-image: url(${item.photo})`"></div>
                    <div class="actor-name">{{item.name}}</div>
                </div>
            </div>
        </div>
        <!-- 用户评论区 -->
        <div class="film-comments">
            <div class="comment-title">相关评论</div>
            <!-- <div class="comment-list">
                <film-comments v-for="(value,index) in comments" :key="index"></film-comments>
            </div> -->
            <film-comments></film-comments>
        </div>
    </div>
</template>
<script>
    const FilmDetail = Vue.extend({
        template: document.currentScript.ownerDocument.querySelector("template"),
        components: {
            bottomBar,
            filmComments
        },
        data(){
            return{
                comments:[],
                details:{}
            }
        },
        computed:{
            getCastList(){
                if(this.details.castList){
                    return JSON.parse(this.details.castList);
                }
            }
        },
        methods:{
            getFilmDetail(id){
                $.ajax({
                    url:"http://localhost/film-project/filmApi/loadFilmById.php",
                    data:{
                        filmId:id
                    },
                    dataType:"json",
                    success:({result})=>{
                        this.details=result;
                        console.log(result);
                    }
                })
            },
        },
        mounted(){
            this.$nextTick(()=>{
                this.getFilmDetail(this.$root.filmId);
               
            })
        }
    })
</script>